package com.paic.mhis.hcpms.audit.dao;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.paic.mhis.hcpms.common.base.dto.PaginatedQueryDTO;
import com.paic.pafa.biz.dao.BaseDAO;

@Component("auditDao")
public class AuditDao extends BaseDAO {

	public Map<String, Object> queryPage(String sqlMapId, PaginatedQueryDTO dto) {
		Map<String, Object> returntMap = new HashMap<String, Object>();
		// 是否查询总数 或者是要分页
		int total = 0;
		if (!dto.getQueryAll() || dto.getDoCount()) {
			total = (Integer) this._getObject(sqlMapId + "Count", dto);
			returntMap.put("total", total);
			if (total > 0) {
				returntMap.put("root", this._list(sqlMapId, dto));
			} else {
				returntMap.put("root", null);
			}
		} else {
			returntMap.put("root", this._list(sqlMapId, dto));
		}

		return returntMap;
	}

	public Map<String, Object> queryTaskPage(PaginatedQueryDTO dto) {
		String sqlStr = "auditDao.findProblemTaskList";
		return queryPage(sqlStr, dto);
	}

	public Map<String, Object> queryTaskAuditPage(PaginatedQueryDTO dto) {
		String sqlStr = "auditDao.findProblemAuditTaskList";
		return queryPage(sqlStr, dto);
	}

	public Map<String, Object> queryProblemByStatus(PaginatedQueryDTO dto) {
		String sqlStr = "auditDao.findProblemListByStatus";
		return queryPage(sqlStr, dto);
	}

	public Map<String, Object> queryCaseTaskPage(PaginatedQueryDTO dto) {
		String sqlStr = "auditDao.findCaseTaskList";
		return queryPage(sqlStr, dto);
	}

	public Map<String, Object> queryCaseAuditTaskPage(PaginatedQueryDTO dto) {
		String sqlStr = "auditDao.findCaseAuditTaskList";
		return queryPage(sqlStr, dto);
	}

	public void saveProblemTemp(String problemCode) {
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		paramsMap.put("problemCode", problemCode);
		this._insert("auditDao.insertProblemTemp", paramsMap);
		this._insert("auditDao.insertTargetTemp", paramsMap);
	}

}
